package cn.tedu.basic;

import java.io.File;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Scanner;

//测试string 字符串
public class Test4 {
    public static void main(String[] args) throws Exception {
        String s =new String();
        //底层是一个char[],叫value，
        char[] c={'s','e','2','y','h','j','q'};
        String s1 =new String(c);
        s1.length();
        byte[] b = s1.getBytes();
        System.out.println(Arrays.toString(b));
        String s2 =String.valueOf(1000);//将其他类型转为string类型
        s1="jnbb kjb kjnb";
        String[] s3 =s1.split("j");
        String[] s4 =s1.split("n",4);
        System.out.println(Arrays.toString(s3));
        System.out.println(Arrays.toString(s4));
        //接收用户输入的字符串
        String s5 =new Scanner(System.in).nextLine();
        for (int i = 0; i <s5.length() ; i++) {
            //获取每个字符
            char c1 =s5.charAt(i);
            System.out.println(c1);
        }
        //拼接字符串
        String s6 ="iudhfvv";
        StringBuilder st =new StringBuilder();
        long start =System.currentTimeMillis();
        for (int i = 0; i <10000 ; i++) {
            st.append(s6);
        }
        long end =System.currentTimeMillis();
        System.out.println(end -start);
        //测试包装类
        Integer in =new Integer(100);
        Integer in1 =Integer.valueOf(100);
        int a =in.intValue();
        System.out.println(a);
        int bb =Integer.parseInt("10000");
        System.out.println(bb);
        System.out.println(bb+100);
        Double d =new Double(55.88);
        Double d1 =Double.valueOf(55.88);
        Double d2 =d.doubleValue();
        Double d3 =d2.doubleValue();
        Double d4 =Double.parseDouble("55.886");
        System.out.println(d4 +d2 +100);
        //测试Date
        Date da =new Date();
        System.out.println(da.getTime());
        System.out.println(da.clone());
        System.out.println(da.getMonth());
        System.out.println(da.getClass());
        System.out.println(da.toLocaleString());
        SimpleDateFormat si =new SimpleDateFormat("yyyy-MM--dd");
        Date da1 =si.parse("1998-04-05");
        System.out.println(da1.getDay());
        System.out.println(da1.getMonth()+1);
        //算天数
        String stt =new Scanner(System.in).nextLine();
        SimpleDateFormat sim =new SimpleDateFormat("yyyy-MM-dd");
        Date dat =sim.parse(stt);
        long sta =dat.getTime();
        long now =System.currentTimeMillis();
        long lo =(now -sta )/1000/60/60/24;
        System.out.println(lo);
        // BigDecimal 小数运算
        double m =new Scanner(System.in).nextDouble();
        double n =new Scanner(System.in).nextDouble();
        BigDecimal m1 =new BigDecimal(m +"");
        BigDecimal n1 =new BigDecimal(n +"");
        System.out.println(m1.add(n1));
        System.out.println(m1.multiply(n1));//乘
        System.out.println(m1.subtract(n1));//减
        System.out.println(m1.divide(n1,3,BigDecimal.ROUND_HALF_UP));
        //测试File
        File fi =new File("D:\\a");
        fi.isDirectory();
        fi.isFile();
        fi.mkdir();
        fi.mkdirs();
        fi.getAbsolutePath();//完整路径
        String[] s7 =fi.list();//获取资源
        System.out.println(Arrays.toString(s7));
        File[] fi1 =fi.listFiles();//获取每个文件file；
        System.out.println(Arrays.toString(fi1));
        File fi2 =fi1[0];
        System.out.println(fi2.length());
        System.out.println(fi2.getName());
        //获取文件夹里所有资源名称
        File f1 =new File("D:\\a");
        File[] f2 =f1.listFiles();
        for (int i = 0; i <f2.length ; i++) {
            File f3 =f2[i];
            if (f3.isFile()){
                System.out.println(f3.getName());
            }else if (f3.isDirectory()){
                System.out.println(f3.getName());
            }
        }

    }
}
